//Copyright 2010 Balazs Keri, Imre Keri
//
//This file is part of FireworksCreator.
//
//FireworksCreator is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//FireworksCreator is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with FireworksCreator.  If not, see <http://www.gnu.org/licenses/>.
//
#ifndef MAINVIEW_H
#define MAINVIEW_H
#include <QString>
#include "view.h"
#include "ui_mainwindow.h"
//
class QSplitter;
class ObjTreeView;
class ObjectsTab;
class SimpleTextView;
class DisplayView;
class Identified;
class ActionDispatcher;
class MainView:public QMainWindow,public View
{
   Q_OBJECT
   Q_DISABLE_COPY(MainView)
//construction
public:
   MainView(QWidget *parent=0);
   ~MainView();
//slots
public slots:
   void do_test();
   void new_fireworks();
   void fireworks_open();
   void fireworks_save();
   void fireworks_save_as();
   void fireworks_close();
   void edit_undo();
   void edit_redo();
   void app_exit();
protected slots:
   void on_root_tree_double_clicked(Identified*);
   void on_document_history_changed();
   void on_document_modified_changed(bool);
//View
protected:
   void handle_set_attr_group();
   void handle_post_primitive_group(const PrimitiveGroup &p_primitive_group);
//QWidget
protected:
   void closeEvent(QCloseEvent *evnt);
//helper functions
private:
   void set_attr_group_all(const QSharedPointer<ViewAttributeGroup> &p_ag);
   void re_create_attr_groups(Document *p_doc);
   void replace_document(Document *p_new_doc);
   bool allowed_to_delete();
   bool try_fireworks_save();
   bool try_fireworks_save_as();
   void re_enable_actions();
   void refresh_window_title();
   void set_modified(bool m);
   void set_undo_redo_actions();
//data
public:
   Ui::MainWindow ui;
   ActionDispatcher *get_act_dispatcher() const;
private:
   QSplitter *central_widget;
   ObjTreeView *root_tree;
   ObjectsTab *objects_tab;
   QPointer<SimpleTextView> stxt_view;
   QPointer<DisplayView> displ_view;
   QString file_name;
   QScopedPointer<ActionDispatcher> dispatcher;
//tmp
private:
   void create_test_view(Identified *p_obj);
};
//
#endif
